import java.util.Random;

public class StudentTask implements Runnable {
    private Semaphore smp;
    private String sno;
    public StudentTask(Semaphore smp, String sno){
        this.smp = smp;
        this.sno= sno;
    }
    public void run() {
        try{
            smp.acquire();
            Random r = new Random();
            int rand = (int)r.nextInt(10)*1000;
//            System.out.println(rand+"+++++++++++++");
            Thread.sleep(rand);
            System.out.println(rand/1000+"秒后，"+Thread.currentThread().getId()+","+sno+"实验完毕");

        } catch (InterruptedException e) {
            e.printStackTrace();
        }finally{
            smp.release();
        }

    }
}
